<?php
/**
 * Created by PhpStorm.
 * User: Lyq
 * Date: 2018/8/22
 * Time: 上午8:21
 */
namespace app\admin\controller;

use think\Exception;
use think\Db;

class Comment extends Common
{
    //评论列表
    public function index()
    {
        $this->templateTitle('评论列表');

        //判断条件
        $where['oc.id']=['gt',0];


        //搜索条件-用户
        $user_condition = request()->param("user_condition");
        $this->assign("user_condition", $user_condition);
        if ($user_condition)
        {
            $where["us.real_name|us.mobile|us.id"] = $user_condition;
        }

        //搜索条件-联盟商
        $un_condition = request()->param("un_condition");
        $this->assign("un_condition", $un_condition);
        if ($un_condition)
        {
            $where["un.title|un.id"] = $un_condition;
        }

        //搜索条件-活动主题
        $ac_condition = request()->param("ac_condition");
        $this->assign("ac_condition", $ac_condition);
        if ($ac_condition)
        {
            $where["ac.title|ac.id"] = $ac_condition;
        }

        //搜索条件-订单
        $or_condition = request()->param("or_condition");
        $this->assign("or_condition", $or_condition);
        if ($or_condition)
        {
            $where["or.id|or.orderid"] = $or_condition;
        }

        //获取评价列表
        $list = Db::name("order_comment")
            ->alias('oc')
            ->join('__USER__ us','us.id=oc.uid','LEFT')
            ->join('__UNION__ un','un.id=oc.union_id','LEFT')
            ->join('__ACTIVE__ ac','ac.id=oc.active_id','LEFT')
            ->join('__ORDER__ or','or.id=oc.order_id','LEFT')
            ->where($where)
            ->order("oc.comment_time DESC")
            ->field('oc.*,us.real_name as uname,us.mobile as umobile,un.title as untitle,ac.title as actitle,or.orderid as ordernum')
            ->paginate(10);
        $this->assign("list", $list);

        return $this->fetch();
    }



}